package org.example.map;

import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import java.util.stream.IntStream;

public class JavaHashMap {
    public static void main(String[] args) {
        test2();
    }

    private static void test2(){
        Map<String,Integer> map = IntStream.range(0,10)
                .collect(
                        LinkedHashMap::new,
                        (m,n) -> m.put(UUID.randomUUID().toString(),m.size()),
                        (m1,m2) ->{}
                );
        map.forEach((k,v) -> System.err.println(k + ":" + v));
    }
    private static void test1() {
        Map<String,Integer> map = IntStream.range(0,10)
        .collect(
                HashMap::new,
                (m,n) -> m.put(UUID.randomUUID().toString(),m.size()),
                (m,m2) ->{}
        );
        map.forEach((k,v) -> System.err.println(k + ":" + v));
        System.err.println(JSONObject.toJSONString(map,true));
    }
}
